from django.urls import path, include
# 导入 djangorestframework-simplejwt 不同的视图，处理Token
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView

from sa.views import account, customer, project, activity, echarts, exportFiles, knowledgeShare, comment

# 开发环境下处理媒体文件
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    # path('userlogin/', account.UserLoginGenericAPIView.as_view()),

    # simpleJWT
    path('userlogin/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),

    # 获取单个用户信息/修改密码
    path('userinfo/<int:pk>/', account.UserInfoGenericAPIView.as_view()),
    # 获取所有用户信息
    path('userinfo/', account.UserAllInfoGenericAPIView.as_view()),
    path('userinfo/region_choices/', account.UserInfoRegionChoicesAPIView.as_view()),

    # 客户信息
    path('customerinfo/', customer.CustomerInfoListGenericAPIView.as_view()),
    path('customerinfo/<int:pk>/', customer.CustomerInfoDetailGenericAPIView.as_view()),
    path('customerinfo/region-choices/', customer.CustomerRegionChoicesAPIView.as_view()),

    # 管理员获取所有项目信息
    path('projectinfo/', project.ProjectInfoGenericAPIView.as_view()),
    # 用户获取自己的项目信息和新增项目
    path('projectinfo-personal/', project.PersonalProjectInfoGenericAPIView.as_view()),
    path('projectinfo-personal/<int:pk>/', project.PersonalProjectInfoDetailGenericAPIView.as_view()),

    # 获取option接口
    path('projectinfo/category-choices/', project.ProjectCategoryChoicesAPIView.as_view()),
    path('projectinfo/software-choices/', project.ProjectSoftwareChoicesAPIView.as_view()),
    path('projectinfo/level-choices/', project.ProjectLevelChoicesAPIView.as_view()),
    path('projectinfo/status-choices/', project.ProjectStatusChoicesAPIView.as_view()),
    path('projectinfo/participants-choices/', project.ProjectParticipantsChoicesAPIView.as_view()),

    # 项目下的activity列表和创建
    path('project/<int:project_pk>/activity/', activity.ActivityInfoGenericAPIView.as_view()),
    # 项目下的activity详情操作
    path('project/<int:project_pk>/activity/<int:pk>/',
         activity.ActivityDetailGenericAPIView.as_view()),

    # 获取Activity 工作分类 options
    path('activity/type-choices/',
         activity.ActivityTypeChoicesAPIView.as_view()),

    # Echarts
    # 项目个数统计
    path('echarts/porject-statistics-monthly/',
         echarts.ProjectStatisticsECharts.as_view()),
    # 项目工作分类列表
    path('echarts/porject-category/',
         echarts.ProjectCategory.as_view()),
    # 按工作分类项目个数统计
    path('echarts/project-statistics-category/',
         echarts.ProjectCountByCategory.as_view()),
    # 项目软件分类列表
    path('echarts/project-software/', echarts.ProjectSoftware.as_view()),
    # 按软件分类统计项目
    path('echarts/project-statistics-software/',
         echarts.ProjectCountBySoftware.as_view()),

    # 导出文件
    path('export/project/', exportFiles.ProjectToFiles.as_view()),
    path('export/activity/', exportFiles.ActivityToFiles.as_view()),
    path('export/project_and_activity/', exportFiles.ProjectAndActivity.as_view()),

    # knowledgeShare
    path('knowledge_share/product_options/',
         knowledgeShare.ProductOptionsAPIView.as_view()),
    path('knowledge_share/knowledge_options/',
         knowledgeShare.KnowledgeOptionsAPIView.as_view()),
    # 所有article 和 新增
    path('knowledge_share/article_list/', knowledgeShare.ArticleAPIView.as_view()),
    # 单个article 操作
    path('knowledge_share/article/<int:pk>/', knowledgeShare.ArticleDetailAPIView.as_view()),
    # 文件上传接口
    # path('knowledge_share/upload/', knowledgeShare.FileUploadAPIView.as_view())

    # 评论comment
    path('article/<int:article_pk>/comment/', comment.CommentView.as_view()),
    path('comment/<int:pk>/', comment.CommentDetailView.as_view()),
]

# 开发环境下添加媒体文件服务   以下代码迁移到项目的urls.py 里, 不能放在子应用里
# if settings.DEBUG:
#     urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
